Skip to content

Resolve Lakebase .env values in non-interactive apps init#4740

Open
pkosiec wants to merge 5 commits intomainfrom
pkosiec/fix-lakebase-env-noninteractive
Open

Resolve Lakebase .env values in non-interactive apps init#4740
pkosiec wants to merge 5 commits intomainfrom
pkosiec/fix-lakebase-env-noninteractive

Conversation

@pkosiec
Copy link
Member

@pkosiec pkosiec commented Mar 13, 2026

Summary

  • Extract ResolvePostgresValues() from PromptForPostgres() so it can be called from the non-interactive code path
  • After --set values are merged in flags mode, resolve derived postgres fields (host, databaseName, endpointPath) by calling ListPostgresEndpoints and ListPostgresDatabases
  • Fixes empty PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT values in .env when using databricks apps init with --set flags

Repro command

Rebuild the CLI and run:

dbx apps init --name event-registration \
        --features lakebase \
        --set "lakebase.postgres.branch=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr" \
        --set "lakebase.postgres.database=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/databases/db-5vqi-xormgdrr0m" \
        --description "Event registration app with Lakebase" \
        --run none --profile DEFAULT --version 0.20.0

Then see if .env has filled PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT:

DATABRICKS_CONFIG_PROFILE=DEFAULT
PGDATABASE=databricks_postgres
LAKEBASE_ENDPOINT=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/endpoints/primary
PGHOST=ep-small-sunset-y12mao90.database.us-west-2.staging.cloud.databricks.com
PGPORT=5432
PGSSLMODE=require
DATABRICKS_APP_PORT=8000
DATABRICKS_APP_NAME=event-registration
FLASK_RUN_HOST=localhost

Test plan

  • Existing unit tests pass (go test ./libs/apps/prompt/... ./cmd/apps/...)
  • Manual test: run the repro command above and verify .env has populated values for PGHOST, PGDATABASE, LAKEBASE_ENDPOINT
  • Verify interactive mode still works unchanged

This pull request was AI-assisted by Isaac.

@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 17:10 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Mar 13, 2026

Commit: 600d082

Run: 23137507142

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 8 9 268 785 5:58
🔄​ aws windows 3 7 9 268 783 5:50
🔄​ aws-ucws linux 2 7 9 364 700 6:49
🔄​ aws-ucws windows 2 7 9 366 698 5:50
💚​ azure linux 2 11 271 783 5:05
💚​ azure windows 2 11 273 781 5:04
💚​ azure-ucws linux 2 11 370 696 7:23
🔄​ azure-ucws windows 2 1 11 371 694 6:37
💚​ gcp linux 2 11 267 786 5:51
💚​ gcp windows 2 11 269 784 5:00
20 interesting tests: 9 SKIP, 7 RECOVERED, 4 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🔄​ TestAccept 💚​R 🔄​f 🔄​f 🔄​f 💚​R 💚​R 💚​R 🔄​f 💚​R 💚​R
🔄​ TestAccept/bundle/deployment/bind/job/generate-and-bind ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🔄​ TestAccept/bundle/deployment/bind/job/generate-and-bind/DATABRICKS_BUNDLE_ENGINE=direct ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_projects/update_display_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/ssh/connect-serverless-gpu 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s ✅​p 🔄​f 🙈​s 🙈​s
💚​ TestAccept/ssh/connection 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 20 slowest tests (at least 2 minutes):
duration env testname
3:45 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:27 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:17 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:11 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:07 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:06 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:02 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:52 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:50 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:48 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:47 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:45 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:38 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:37 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:17 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:17 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:14 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:11 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:10 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:06 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@pkosiec pkosiec force-pushed the pkosiec/fix-lakebase-env-noninteractive branch from 7538829 to 9f516e6 Compare March 13, 2026 19:09
@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 19:10 — with GitHub Actions Inactive
@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 19:18 — with GitHub Actions Inactive
@pkosiec pkosiec force-pushed the pkosiec/fix-lakebase-env-noninteractive branch from b55fc9b to f282f3a Compare March 13, 2026 19:27
@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 19:28 — with GitHub Actions Inactive
@pkosiec pkosiec force-pushed the pkosiec/fix-lakebase-env-noninteractive branch from f282f3a to af7233d Compare March 16, 2026 08:56
@pkosiec pkosiec temporarily deployed to test-trigger-is March 16, 2026 08:56 — with GitHub Actions Inactive
pkosiec added 4 commits March 16, 2026 10:34
When running `databricks apps init` with `--set` flags (non-interactive mode),
the `.env` file had empty values for PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT.
These fields have a `Resolve` property that maps them to values derived from the
selected branch. In interactive mode, `PromptForPostgres()` runs the full
resolution flow, but in non-interactive mode no resolution logic ran.

Extract the resolution logic into a new `ResolvePostgresValues()` function and
call it from the non-interactive path after `--set` values are merged.

Co-authored-by: Isaac
Extract ResolvePostgresValues from PromptForPostgres to reuse resolution
of derived postgres fields (host, databaseName, endpointPath) in the
non-interactive/flags code path. Consolidate CollectResources calls.

Co-authored-by: Isaac
- Restore RunWithSpinnerCtx in interactive PromptForPostgres for the
  ResolvePostgresValues call to maintain UX feedback during API calls
- Add TestResolvePostgresValuesDatabaseAPIError to cover ListDatabases
  failure path
- Fix comment in init.go to say "derived values" instead of
  "derived postgres values" since the resolve loop is generic

Co-authored-by: Isaac
@pkosiec pkosiec force-pushed the pkosiec/fix-lakebase-env-noninteractive branch from d951298 to 2835416 Compare March 16, 2026 09:34
@pkosiec pkosiec temporarily deployed to test-trigger-is March 16, 2026 09:34 — with GitHub Actions Inactive
@pkosiec pkosiec marked this pull request as ready for review March 16, 2026 09:46
@pkosiec pkosiec requested a review from a team as a code owner March 16, 2026 09:46
@pkosiec pkosiec temporarily deployed to test-trigger-is March 16, 2026 09:46 — with GitHub Actions Inactive
@pkosiec pkosiec requested a review from MarioCadenas March 16, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants